package com.trip.admin;

import com.trip.api.ControllerResult;
import com.trip.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by hc24 on 2018/5/2.
 */
@Controller
public class ImportController {

    @Autowired
    private DataService dataService;

    @RequestMapping("/admin/import/history")
    public String queryHistory(Model model){
        model.addAttribute("historyList",dataService.queryHistory());
        return "import";
    }

    @RequestMapping("/admin/import/start")
    @ResponseBody
    public ControllerResult importATLAS(){
        dataService.manualImportTask();
        return ControllerResult.success();

    }

    @RequestMapping("/admin/import/debug/yes")
    @ResponseBody
    public ControllerResult openDebug(int pageNum){
        DataService.IS_DEBUG=true;
        DataService.DEBUG_PAGE_NUM=pageNum;
        return ControllerResult.success();
    }

    @RequestMapping("/admin/import/debug/no")
    @ResponseBody
    public ControllerResult closeDebug(){
        DataService.IS_DEBUG=false;
        return ControllerResult.success();
    }

    @RequestMapping("/admin/importTest")
    @ResponseBody
    public ControllerResult importTest(){
        dataService.test();
        return ControllerResult.success();
    }





}
